Object–Oriented Tokens for the Parser Generator jay

نویسندگان

  • Holger Haas
  • Martin Plümicke
چکیده

jay is a parser generator for JAVA derived from ATTs’ parser generator yacc, which was designed for the C programming language. Being based on yacc, jay is not well adapted for object-orientation, because this principle is not known in the C-world. To correct this flaw jay was redesigned to cope with objects. 1 The Parser Generator jay The parser generator jay [1] is a tool which generates for a given grammar in BNF a respective parser in JAVA. The specification of jay is very similar to that of yacc [2]. This means that it is very easy to learn jay for a yacc user. But there are some significant differences, which arises from the fact that JAVA is object–oriented and the original yacc bases on C: The generated JAVA program is parameterized by the JAVA interface yyInput: boolean advance () throws java.io.IOException; int token (); Object value (); The method advance() reads the next lexem and gives false if end-of-file is reached. The method token() gives the corresponding token. Finally, the method value() is used to get the corresponding object for the jay’s value–stack. This interface must be implemented by the user, himself. For the implementation of advance() and token() a scanner is needed. The simplest possibility is to implement a subclass of the JAVA’s stringtokenizer. More comfortable is for example to use JLex [3]. JLex is a generator for a lexical analyzer. It bases on the well-known lex [2] but produces JAVA code and is written in JAVA. The design approach of JLex is object–oriented, which means that the produced tokens can be real objects (instances of classes, not only ints). In contrast jay accepts, as yacc, only int values as tokens.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Studying impressive parameters on the performance of Persian probabilistic context free grammar parser

In linguistics, a tree bank is a parsed text corpus that annotates syntactic or semantic sentence structure. The exploitation of tree bank data has been important ever since the first large-scale tree bank, The Penn Treebank, was published. However, although originating in computational linguistics, the value of tree bank is becoming more widely appreciated in linguistics research as a whole. F...

متن کامل

A First Implementation of Modular Smalltalk

A "first" implementation of the Modular Smalltalk object-oriented programming language is presented. The implementation includes an object-oriented parser, object-oriented representation for code fragments and an object-oriented C-code generator, all implemented in Smalltalk-80. This implementation validates two of the five design principles of the Modular Smalltalk language and provides a vehi...

متن کامل

An object oriented approach to parser generation in C++

In this paper we describe the design and implementation of a system for representing context-free grammars in C++. The system allows for grammar representation at the object level, providing enhanced modularity and flexibility when compared to traditional generator-based approaches. We also describe the transformation of grammar flow analysis problems into an object-oriented framework using the...

متن کامل

Practical Packrat Parsing

A considerable number of research projects are exploring how to extend object-oriented programming languages such as Java with, for example, support for generics, multiple dispatch, or pattern matching. To keep up with these changes, language implementors need appropriate tools. In this context, easily extensible parser generators are especially important because parsing program sources is a ne...

متن کامل

The Afit Wide Spectrum Object Modeling Environment: an Awsome Beginning

Over the past several years, the Air Force Institute of Technology (AFIT) has been developing a formal-based software synthesis system, the AFIT Wide Spectrum Object Modeling Environment (AWSOME), along with a speci cation language AWL (AFIT Wide-spectrum Language). Several tools have been developed, including a parser for the AWL syntax, an interactive object editor, a Java code generator, and...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2005